package com.xitang.customer.controller;

import com.xitang.common.bean.BizCondition;
import com.xitang.common.dto.ResultVO;
import com.xitang.common.service.IConditionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(tags = "条件接口列表-客户")
@RestController
public class BizConditionController extends BaseCustomerController {
    @Autowired
    private IConditionService iConditionService;

    @Value("${qiniu.domain}")
    private String domain;

    @ApiOperation(value = "获取查询条件", notes = "获取查询条件")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "conditionTagCode", value = "条件类别，color|material|style", dataType = "String")
    })
    @GetMapping("/condition/{conditionTagCode}")
    public ResultVO<List<BizCondition>> listConditions(@PathVariable(value = "conditionTagCode") String conditionTagCode) {
        List<BizCondition> bizConditions = iConditionService.listConditions(conditionTagCode);
        Map<String, Object> headers = new HashMap<>();
        headers.put("domain", domain);
        headers.put("totalCount", bizConditions.size());
        return ResultVO.success(bizConditions, headers);
    }
}
